<div class="easyui-layout" data-options="fit:true" style="width:100%;height:100%;">
	<div data-options="region:'center'" style="padding:5px 6px 0px 6px;border:0px;">
		<div id="system-config-tabs" class="easyui-tabs" style="width:100%;height:100%;" data-options="fit:true,plain:true">
			<div title="基本信息" style="padding:5px;padding-right:10px;" class="dialog">
				<table style="width:100%;">
					<tr>
						<td width="100%" colspan="2">
							<span id="system-config-download-dir"></span>
							<span style="float:right;">(<span id="system-config-download-dir-free-space"></span><span id="download-dir-free-space"></span>)</span>
						</td>
					</tr>
					<tr>
						<td colspan="2"><select id="download-dir" style="width:573px;"></select></td>
					</tr>
					<tr>
						<td colspan="2"><input id="incomplete-dir-enabled" type="checkbox" style="width:16px;"/><label id="system-config-incomplete-dir-enabled" for="incomplete-dir-enabled"></label></td>
					</tr>
					<tr>
						<td colspan="2"><input id="incomplete-dir" value="" type="text" enabledof="incomplete-dir-enabled"/></td>
					</tr>
					<tr>
						<td colspan="2"><input id="rename-partial-files" type="checkbox" style="width:16px;"/><label id="system-config-rename-partial-files" for="rename-partial-files"></label></td>
					</tr>
					<tr>
						<td colspan="2"><input id="start-added-torrents" type="checkbox" style="width:16px;"/><label id="system-config-start-added-torrents" for="start-added-torrents"></label></td>
					</tr>
					<tr>
						<td colspan="2"><hr/></td>
					</tr>
					<tr>
						<td width="65%"><span id="system-config-cache-size-mb"></span></td>
						<td width="35%"><input id="cache-size-mb" value="" type="text" class="easyui-numberspinner"/> MB</td>
					</tr>
					<tr>
						<td colspan="2"><hr/></td>
					</tr>
					<tr>
						<td colspan="2">
							<span id="system-config-config-dir"></span>
						</td>
					</tr>
					<tr>
						<td colspan="2"><input id="config-dir" value="" type="text" readonly="readonly" disabled="disabled"/></td>
					</tr>
					<tr>
						<td colspan="2"><hr/></td>
					</tr>
					<tr>
						<td colspan="2" align="right">
							<span>Language：</span><select id="system-config-lang" value="" style="width:200px;"></select>
						</td>
					</tr>
				</table>
			</div>
			<div title="网络" style="padding:5px;padding-right:10px;" class="dialog">
				<table style="width:100%;">
					<tr>
						<td width="65%">
							<input id="download-queue-enabled" type="checkbox" style="width:16px;"/><label id="system-config-download-queue-enabled" for="download-queue-enabled"></label>
						</td>
						<td width="35%"><input id="download-queue-size" value="" type="text" class="easyui-numberspinner" enabledof="download-queue-enabled"/></td>
					</tr>
					<tr>
						<td>
							<input id="seed-queue-enabled" type="checkbox" style="width:16px;"/><label id="system-config-seed-queue-enabled" for="seed-queue-enabled"></label>
						</td>
						<td><input id="seed-queue-size" value="" type="text" class="easyui-numberspinner" enabledof="seed-queue-enabled"/></td>
					</tr>
					<tr>
						<td colspan="2"><hr/></td>
					</tr>
					<tr>
						<td>
							<span id="system-config-encryption"></span>
						</td>
						<td>
							<select id="encryption" class="easyui-combobox" data-options="editable:false"></select>
						</td>
					</tr>
					<tr>
						<td valign="top">
							<input id="peer-port-random-on-start" type="checkbox" style="width:16px;"/><label id="system-config-peer-port-random-on-start" for="peer-port-random-on-start"></label>
						</td>
						<td>
							<input id="peer-port" value="" type="text" class="easyui-numberspinner" style="width:70px;"/> <a id="system-config-test-port" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-test-port'"></a>
						</td>
					</tr>
					<tr>
						<td>
							<input id="port-forwarding-enabled" type="checkbox" style="width:16px;"/><label id="system-config-port-forwarding-enabled" for="port-forwarding-enabled"></label>
						</td>
						<td>
							<span id="system-config-port-is-open-true" style="display:none;color:#339900;"></span>
							<span id="system-config-port-is-open-false" style="display:none;color:red;"></span>
						</td>
					</tr>
					<tr>
						<td>
							<input id="lpd-enabled" type="checkbox" style="width:16px;"/><label id="system-config-lpd-enabled" for="lpd-enabled"></label>
						</td>
						<td>
							<input id="utp-enabled" type="checkbox" style="width:16px;"/><label id="system-config-utp-enabled" for="utp-enabled"></label>
						</td>
					</tr>
					<tr>
						<td>
							<input id="dht-enabled" type="checkbox" style="width:16px;"/><label id="system-config-dht-enabled" for="dht-enabled"></label>
						</td>
						<td>
							<input id="pex-enabled" type="checkbox" style="width:16px;"/><label id="system-config-pex-enabled" for="pex-enabled"></label>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<hr/>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<input id="blocklist-enabled" type="checkbox" style="width:16px;"/><label id="system-config-blocklist-enabled" for="blocklist-enabled"></label>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<input id="blocklist-url" type="text" enabledof="blocklist-enabled"/>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<span id="system-config-blocklist-size" system-lang="dialog['system-config']['blocklist-size']"></span>
							<button id="system-conifg-button-update-blocklist" system-lang="dialog['public']['button-update']" enabledof="blocklist-enabled"></button>
						</td>
					</tr>
				</table>
			</div>
			<div title="带宽" style="padding:5px;padding-right:10px;" class="dialog">
				<table style="width:100%;">
					<tr>
						<td width="65%">
							<input id="speed-limit-down-enabled" type="checkbox" style="width:16px;"/><label id="system-config-speed-limit-down-enabled" for="speed-limit-down-enabled"></label>
						</td>
						<td width="35%"><input id="speed-limit-down" value="" type="text" class="easyui-numberspinner" enabledof="speed-limit-down-enabled"/> KB/s</td>
					</tr>
					<tr>
						<td>
							<input id="speed-limit-up-enabled" type="checkbox" style="width:16px;"/><label id="system-config-speed-limit-up-enabled" for="speed-limit-up-enabled"></label>
						</td>
						<td><input id="speed-limit-up" value="" type="text" class="easyui-numberspinner" enabledof="speed-limit-up-enabled"/> KB/s</td>
					</tr>
					<tr>
						<td colspan="2">
							<hr/>
						</td>
					</tr>
					<tr>
						<td>
							<span id="system-config-peer-limit-global"></span>
						</td>
						<td>
							<input id="peer-limit-global" value="" type="text" class="easyui-numberspinner"/>
						</td>
					</tr>
					<tr>
						<td>
							<span id="system-config-peer-limit-per-torrent"></span>
						</td>
						<td>
							<input id="peer-limit-per-torrent" value="" type="text" class="easyui-numberspinner"/>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<hr/>
						</td>
					</tr>
					<tr>
						<td>
							<input id="seedRatioLimited" type="checkbox" style="width:16px;"/><label id="system-config-seedRatioLimited" for="seedRatioLimited"></label>
						</td>
						<td><input id="seedRatioLimit" value="" type="text" class="easyui-numberspinner" enabledof="seedRatioLimited"/></td>
					</tr>
					<tr>
						<td>
							<input id="idle-seeding-limit-enabled" type="checkbox" style="width:16px;"/><label id="system-config-idle-seeding-limit-enabled" for="idle-seeding-limit-enabled"></label>
						</td>
						<td><input id="idle-seeding-limit" value="" type="text" class="easyui-numberspinner" enabledof="idle-seeding-limit-enabled"/> <span name="system-config-minuets"></span></td>
					</tr>
					<tr>
						<td>
							<input id="queue-stalled-enabled" type="checkbox" style="width:16px;"/><label id="system-config-queue-stalled-enabled" for="queue-stalled-enabled"></label>
						</td>
						<td><input id="queue-stalled-minutes" value="" type="text" class="easyui-numberspinner" enabledof="queue-stalled-enabled"/> <span name="system-config-minuets"></span></td>
					</tr>
				</table>
			</div>
			<div title="时段" style="padding:5px;" class="dialog">
				<fieldset>
					<table style="width:100%;">
						<tr>
							<td width="65%">
								<span id="system-config-alt-speed-down"></span>
							</td>
							<td width="35%"><input id="alt-speed-down" value="" type="text" class="easyui-numberspinner" _enabledof="alt-speed-enabled"/> KB/s</td>
						</tr>
						<tr>
							<td>
								<label id="system-config-alt-speed-up"></label>
							</td>
							<td><input id="alt-speed-up" value="" type="text" class="easyui-numberspinner" _enabledof="alt-speed-enabled"/> KB/s</td>
						</tr>
					</table>
				</fieldset>
				<fieldset>
					<legend id="">
						<input id="alt-speed-time-enabled" type="checkbox" style="width:16px;"/><label id="system-config-alt-speed-time-enabled" for="alt-speed-time-enabled"></label>
					</legend>
					<table style="width:100%;">
						<tr>
							<td>
								<span id="system-config-alt-speed-time"></span>
								<input id="alt-speed-time-begin" value="" type="text" class="easyui-timespinner" style="width:80px;" enabledof="alt-speed-time-enabled"/> -
								<input id="alt-speed-time-end" value="" type="text" class="easyui-timespinner" style="width:80px;" enabledof="alt-speed-time-enabled"/>
							</td>
						</tr>
						<tr>
							<td style="padding:10px 0px 5px 0px;">
								<input id="alt-speed-time-weekday-1" type="checkbox" style="width:16px;" enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-1" for="alt-speed-time-weekday-1"></label>
								<input id="alt-speed-time-weekday-2" type="checkbox" style="width:16px;" enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-2" for="alt-speed-time-weekday-2"></label>
								<input id="alt-speed-time-weekday-3" type="checkbox" style="width:16px;" enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-3" for="alt-speed-time-weekday-3"></label>
								<input id="alt-speed-time-weekday-4" type="checkbox" style="width:16px;" enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-4" for="alt-speed-time-weekday-4"></label>
								<input id="alt-speed-time-weekday-5" type="checkbox" style="width:16px;" enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-5" for="alt-speed-time-weekday-5"></label>
								<input id="alt-speed-time-weekday-6" type="checkbox" style="width:16px;" enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-6" for="alt-speed-time-weekday-6"></label>
								<input id="alt-speed-time-weekday-0" type="checkbox" style="width:16px;" enabledof="alt-speed-time-enabled"/><label id="system-config-weekday-0" for="alt-speed-time-weekday-0"></label>
							</td>
						</tr>
					</table>
				</fieldset>
				<input id="alt-speed-enabled" type="checkbox" style="width:16px;"/><label id="system-config-alt-speed-enabled" for="alt-speed-enabled"></label>
			</div>
			<div title="目录字典" style="padding:5px;padding-right:10px;" class="dialog">
				<table style="width:100%;height:100%;">
					<tr>
						<td width="100%" height="100%">
							<textarea id="local-storage-dictionary-folders" style="width:100%;height:100%;"></textarea>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>  
	<div data-options="region:'south',border:false" style="text-align:right;padding:6px;">
		<a id="system-config-button-reload" href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'" style="float:left;display:none;"></a>
		<span id="system-config-nochange" style="display:none;"></span>
		<span id="system-config-saved" style="display:none;"></span>
		<a id="system-config-button-save" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" href="javascript:void(0);">Ok</a>
		<a id="system-config-button-cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" href="javascript:void(0);">Cancel</a>
	</div>
</div>
<script type="text/javascript">
	(function(thisDialog){
		var title = "button-save,button-cancel,button-reload".split(",");
		$.each(title, function(i, item){
			thisDialog.find("#system-config-"+item).html(system.lang.dialog.public[item]);
		});

		system.resetLangText(thisDialog);
		thisDialog.find("#system-config-blocklist-size").html(system.lang.dialog['system-config']['blocklist-size'].replace("%n",system.serverConfig["blocklist-size"]));

		var tabs = thisDialog.find("#system-config-tabs");
		tabs.tabs();
		var base = tabs.tabs("getTab",0);

		tabs.tabs("update",{
			tab:tabs.tabs("getTab",0)
			,options:{
				title:system.lang.dialog["system-config"].tabs.base
			}
		});
		tabs.tabs("update",{
			tab:tabs.tabs("getTab",1)
			,options:{
				title:system.lang.dialog["system-config"].tabs.network
			}
		});
		tabs.tabs("update",{
			tab:tabs.tabs("getTab",2)
			,options:{
				title:system.lang.dialog["system-config"].tabs.limit
			}
		});
		tabs.tabs("update",{
			tab:tabs.tabs("getTab",3)
			,options:{
				title:system.lang.dialog["system-config"].tabs["alt-speed"]
			}
		});
		tabs.tabs("update",{
			tab:tabs.tabs("getTab",4)
			,options:{
				title:system.lang.dialog["system-config"].tabs["dictionary-folders"]
			}
		});

		// 设置语言
		$.each(system.languages, function(key, value){
			$("<option/>").text(value).val(key).attr("selected",(key==system.lang.name?true:false)).appendTo(thisDialog.find("#system-config-lang"));
		});

		title = ("config-dir,download-dir,incomplete-dir-enabled,cache-size-mb,rename-partial-files,download-dir-free-space,start-added-torrents"
					+",download-queue-enabled,seed-queue-enabled,encryption,peer-port-random-on-start,speed-limit-down-enabled,speed-limit-up-enabled"
					+",alt-speed-enabled,alt-speed-down,alt-speed-up,test-port,port-forwarding-enabled,utp-enabled,dht-enabled,lpd-enabled,pex-enabled"
					+",peer-limit-global,peer-limit-per-torrent,blocklist-enabled,seedRatioLimited,queue-stalled-enabled,idle-seeding-limit-enabled"
					+",alt-speed-time-enabled,alt-speed-time,nochange,port-is-open-true,port-is-open-false"
					).split(",");
		$.each(title, function(i, item){
			thisDialog.find("#system-config-"+item).html(system.lang.dialog["system-config"][item]);
		});

		thisDialog.find("span[name='system-config-minuets']").html(system.lang.dialog["system-config"]["minuets"]);

		// 置换系统参数
		title = ("incomplete-dir-enabled,rename-partial-files,start-added-torrents,download-queue-enabled,seed-queue-enabled"
					+",peer-port-random-on-start,speed-limit-down-enabled,speed-limit-up-enabled,alt-speed-enabled,idle-seeding-limit-enabled"
					+",port-forwarding-enabled,utp-enabled,dht-enabled,lpd-enabled,pex-enabled,blocklist-enabled,seedRatioLimited,queue-stalled-enabled"
					+",alt-speed-time-enabled"
					).split(",");
		$.each(title, function(i, item){
			thisDialog.find("#"+item).prop("checked",system.serverConfig[item])
			.click(function(){
				thisDialog.find("*[enabledof='"+this.id+"']").prop("disabled",!this.checked);
			});
		});
		
		// 设置内容
		thisDialog.find("#download-dir").val(system.downloadDir);
		$.each(transmission.downloadDirs, function(i, item){
			$("<option/>").text(item).val(item).attr("selected",(item==system.downloadDir?true:false)).appendTo(thisDialog.find("#download-dir"));
		});
		if (transmission.downloadDirs.length==0)
		{
			$("<option/>").text(system.downloadDir).val(system.downloadDir).attr("selected",true).appendTo(thisDialog.find("#download-dir"));
		}
		thisDialog.find("#download-dir").combobox();
		
		thisDialog.find("#config-dir").val(system.serverConfig["config-dir"]);
		thisDialog.find("#incomplete-dir").val(system.serverConfig["incomplete-dir"]);
		thisDialog.find("#incomplete-dir").prop("disabled",!system.serverConfig["incomplete-dir-enabled"]);
		thisDialog.find("#cache-size-mb").val(system.serverConfig["cache-size-mb"]);
		thisDialog.find("#download-queue-size").val(system.serverConfig["download-queue-size"]).prop("disabled",!system.serverConfig["download-queue-enabled"]);
		thisDialog.find("#seed-queue-size").val(system.serverConfig["seed-queue-size"]).prop("disabled",!system.serverConfig["seed-queue-enabled"]);
		thisDialog.find("#peer-port").val(system.serverConfig["peer-port"]).prop("disabled",system.serverConfig["peer-port-random-on-start"]);
		
		thisDialog.find("#speed-limit-down").val(system.serverConfig["speed-limit-down"]).prop("disabled",!system.serverConfig["speed-limit-down-enabled"]);
		thisDialog.find("#speed-limit-up").val(system.serverConfig["speed-limit-up"]).prop("disabled",!system.serverConfig["speed-limit-up-enabled"]);

		thisDialog.find("#alt-speed-down").val(system.serverConfig["alt-speed-down"]);
		thisDialog.find("#alt-speed-up").val(system.serverConfig["alt-speed-up"]);
		
		thisDialog.find("#alt-speed-time-begin").val(getHoursFromMinutes(system.serverConfig["alt-speed-time-begin"])).prop("disabled",!system.serverConfig["alt-speed-time-enabled"]);
		thisDialog.find("#alt-speed-time-end").val(getHoursFromMinutes(system.serverConfig["alt-speed-time-end"])).prop("disabled",!system.serverConfig["alt-speed-time-enabled"]);
		
		var days = ("0000000"+system.serverConfig["alt-speed-time-day"].toString(2)).right(7).split("").reverse();
		var weekday = system.lang.dialog["system-config"]["weekday"];
		//初始化星期
		for (var day in weekday)
		{
			thisDialog.find("#alt-speed-time-weekday-"+day).prop("checked",(days[day]==1?true:false)).prop("disabled",!system.serverConfig["alt-speed-time-enabled"]);
			thisDialog.find("#system-config-weekday-"+day).text(weekday[day]);
		}
		
		thisDialog.find("#peer-limit-global").val(system.serverConfig["peer-limit-global"]);
		thisDialog.find("#peer-limit-per-torrent").val(system.serverConfig["peer-limit-per-torrent"]);
		
		thisDialog.find("#blocklist-url").val(system.serverConfig["blocklist-url"]).prop("disabled",!system.serverConfig["blocklist-enabled"]);
		thisDialog.find("#system-conifg-button-update-blocklist").prop("disabled",!system.serverConfig["blocklist-enabled"]);

		thisDialog.find("#seedRatioLimit").val(system.serverConfig["seedRatioLimit"]).prop("disabled",!system.serverConfig["seedRatioLimited"]);
		thisDialog.find("#queue-stalled-minutes").val(system.serverConfig["queue-stalled-minutes"]).prop("disabled",!system.serverConfig["queue-stalled-enabled"]);
		thisDialog.find("#idle-seeding-limit").val(system.serverConfig["idle-seeding-limit"]).prop("disabled",!system.serverConfig["idle-seeding-limit-enabled"]);
		
		var etype = system.lang.dialog["system-config"]["encryption-type"];
		for (var key in etype)
		{
			$("<option/>").val(key).attr("selected",(key==system.serverConfig["encryption"]?true:false)).text(etype[key]).appendTo(thisDialog.find("#encryption"));
		}


		var tmp = system.serverConfig["download-dir-free-space"];
		if (tmp==-1)
		{
			tmp = system.lang.public["text-unknown"];
		}
		else
		{
			tmp = formatSize(tmp);
		}
		thisDialog.find("#download-dir-free-space").text(tmp);

		// 本地设置信息
		thisDialog.find("#local-storage-dictionary-folders").val(system.dictionary.folders);


		// 取消
		thisDialog.find("#system-config-button-cancel").click(function()
		{
			thisDialog.dialog("close");
		});
		/**/	
		// 测试端口
		thisDialog.find("#system-config-test-port").click(function()
		{
			var button = $(this);
			button.linkbutton({text:system.lang.dialog["system-config"].testing,disabled:true});
			// 如果端口有变更，则先保存
			if (parseInt(thisDialog.find("#peer-port").val())!=system.serverConfig["peer-port"])
			{
				transmission.exec(
					{
						method:"session-set"
						,arguments:{"peer-port":true}
					}
					,function(data){
						if (data.result=="success")
						{
							transmission.exec(
								{
									method:"port-test"
								}
								,function(data){
									if (data.result=="success")
									{
										if (data.arguments["port-is-open"])
										{
											thisDialog.find("#system-config-port-is-open-true").fadeInAndOut();
										}
										else
										{
											thisDialog.find("#system-config-port-is-open-false").fadeInAndOut();
										}
									}
									button.linkbutton({text:system.lang.dialog["system-config"]["test-port"],disabled:false});
								}
							);
						}
					}
				);
			}
			else
			{
				transmission.exec(
					{
						method:"port-test"
					}
					,function(data){
						if (data.result=="success")
						{
							if (data.arguments["port-is-open"])
							{
								thisDialog.find("#system-config-port-is-open-true").fadeInAndOut();
							}
							else
							{
								thisDialog.find("#system-config-port-is-open-false").fadeInAndOut();
							}
							button.linkbutton({text:system.lang.dialog["system-config"]["test-port"],disabled:false});
						}
					}
				);
			}
		});
	
		// 保存参数
		thisDialog.find("#system-config-button-save").click(function()
		{
			var inputs = thisDialog.find("input");
			var config = {};
			var days = new Array();
			var value = null;
			for (var key in inputs)
			{
				var input = inputs[key];
				value = null;
				if (input.id!=undefined&&input.id!="")
				{
					switch (input.type)
					{
						case "checkbox":
							switch (input.id)
							{
								// 星期
								case "alt-speed-time-weekday-0":
								case "alt-speed-time-weekday-1":
								case "alt-speed-time-weekday-2":
								case "alt-speed-time-weekday-3":
								case "alt-speed-time-weekday-4":
								case "alt-speed-time-weekday-5":
								case "alt-speed-time-weekday-6":
									days.push(input.checked?1:0);
									break;
								default:
									value = input.checked;
									break;
							}
							break;
						default:
							switch (input.id)
							{
								// 限制时间
								case "alt-speed-time-begin":
								case "alt-speed-time-end":
									value = getMinutesFromHours(input.value);
									break;

								default:
									value = ($.isNumeric(input.value)?parseFloat(input.value):input.value);
									break;
							}
							break;
					}

					if (value!=system.serverConfig[input.id]&&value!=null)
					{
						config[input.id] = value;
					}
				}
			}
			//console.log("days:",days);
			var sunday = days.pop();
			//console.log("days1:",days);
			days.unshift(sunday);
			value = parseInt(days.reverse().join(""),2);
			if (value!=system.serverConfig["alt-speed-time-day"]&&value!=null)
			{
				config["alt-speed-time-day"]=value;
			}
			value = thisDialog.find("#encryption").combobox("getValue");
			if (value!=system.serverConfig["encryption"]&&value!=null)
			{
				config["encryption"]=value;
			}
			
			value = thisDialog.find("#download-dir").combobox("getValue");
			if (value!=system.serverConfig["download-dir"]&&value!=null)
			{
				config["download-dir"]=value;
			}

			var cuslang = thisDialog.find("#system-config-lang").val();
			
			// 如果参数有改变则保存
			if (!$.isEmptyObject(config))
			{
				$(this).linkbutton({text:system.lang.dialog["system-config"].saveing,disabled:true});
				// 开始设置参数
				transmission.exec(
					{
						method:"session-set"
						,arguments:config
					}
					,function(data){
						if (data.result=="success")
						{
							// 设置成功后，重新获取当前参数
							transmission.exec(
								{
									method:"session-get"
								}
								,function(data){
									if (data.result=="success")
									{
										system.serverConfig = data.arguments;
										$("#status_version").html(system.lang.statusbar.version+data.arguments["version"]);
										if (data.arguments["alt-speed-enabled"]==true)
										{
											system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"icon-alt-speed-true"});
											$("#status_alt_speed").show();
										}
										else
										{
											system.panel.toolbar.find("#toolbar_alt_speed").linkbutton({iconCls:"icon-alt-speed-false"});
											$("#status_alt_speed").hide();
										}
										
										system.downloadDir = data.arguments["download-dir"];
										saveLocalData();
										
										if (cuslang!=system.lang.name)
										{
											system.changeLanguages(cuslang);
										}
									}
								}
							);
						}
					}
				);
				return;
			}
			// 如果語言改變時，重新加載頁面
			else if (cuslang!=system.lang.name)
			{
				system.changeLanguages(cuslang);
			}
			else
			{
				if (system.dictionary.folders == thisDialog.find("#local-storage-dictionary-folders").val())
				{
					thisDialog.find("#system-config-nochange").fadeInAndOut();
					return;
				}
			}

			saveLocalData();
			// 保存本地数据
			function saveLocalData()
			{
				system.dictionary.folders = thisDialog.find("#local-storage-dictionary-folders").val();
				system.saveConfig();
				thisDialog.dialog("close");
			}

			//console.log("config:",config);
		});


		// 更新黑名單
		thisDialog.find("#system-conifg-button-update-blocklist").click(function(){
			var button = $(this);
			button.prop("disabled",true);
			transmission.updateBlocklist(function(data){
				if (data.result=="success")
				{
					thisDialog.find("#system-config-blocklist-size").html(system.lang.dialog['system-config']['blocklist-size'].replace("%n",data.arguments["blocklist-size"]));
				};
				button.prop("disabled",false);
			});
		});
	})($("#dialog-system-config"));
</script>